<%--
    Document   : buscarTeatro
    Created on : May 29, 2010, 1:17:33 PM
    Author     : williamprado
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
    HttpSession currentSession = request.getSession();
    if(currentSession.getAttribute("usuario")!=null){
        currentSession.removeAttribute("usuario");
        currentSession.invalidate();
    }
    String msg = (String)currentSession.getAttribute("msg");
    if (msg == null){msg = "";}
    java.util.List<VOs.Country> countries = new java.util.ArrayList<VOs.Country>();
    java.util.List<VOs.City> cities = new java.util.ArrayList<VOs.City>();
    java.util.List<DTOs.DTOTeatros> theaters = new java.util.ArrayList<DTOs.DTOTeatros>();
    int a = 0;
    try{
        countries = (java.util.List<VOs.Country>) currentSession.getAttribute("countryList");
        cities = (java.util.List<VOs.City>) currentSession.getAttribute("cityList");
        theaters = (java.util.List<DTOs.DTOTeatros>) currentSession.getAttribute("theaterList");;
        a = (Integer) currentSession.getAttribute("selectedCountry");
    }catch(Exception e){
        countries = new java.util.ArrayList<VOs.Country>();
        cities = new java.util.ArrayList<VOs.City>();
        theaters = null;
        a = 0;
    }
    if(cities == null){
        cities = new java.util.ArrayList<VOs.City>();
    }
%>
<html>
    <head>
        <title>FuTurismo - Haga sus reservas de forma facil y rapida - Buscar Teatros</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link href="css/styles.css" rel="stylesheet" type="text/css" />
        <script src="js/Encriptacion.js" type="text/javascript"></script>
        <script language="JavaScript" src="js/calendar_us.js"></script>
        <link rel="stylesheet" href="js/calendar.css">
    </head>


    <jsp:include page="fragment/top.jsp"/>
    <center>
        <jsp:include page="fragment/subTop.jsp"/>
        <div id="fond" class="clear-block">
            <table><tbody><tr><td >
                    <jsp:include page="fragment/left.jsp"/>

                <!columna dos para la parte central de la pagina>

                    <div id="central" class="clear-block" >
                        <h1>Buscar Obras de Teatro</h1>
                        <p align="center"><img src="archivos/theatre.jpg" width="95%"></p>
                        <p align="justify">Especifique una ciudad y una fecha para buscar
                            obras de teatro disponibles.</p>
                        <hr>
                        <form name="countryForm" action="navigationServlet" method="post">
                            <table width="100%" align="center">
                                <input type="hidden" name="target" value="getCitiesT"/>
                                <tr><td colspan="2"><select name="country" onchange="submit();"><%for(int i=0;i<countries.size();i++){%>
                                                    <option <%if(i+1 == a){%>selected<%}%>><%=countries.get(i).getName()%></option>
                                                  <%}%></select></td></tr>
                            </table>
                        </form>
                        <form name="searchTheatersForm" action="TheatersServlet" method="post">
                        <table width="100%" align="center">
                            <input type="hidden" name="action" value="searchTheaters"/>
                            <tr><td colspan="2"><select name="city"><%for(int i=0;i<cities.size();i++){%>
                                                    <option><%=cities.get(i).getName()%></option>
                                                  <%}%></select></td></tr>
                            <tr><td>Fecha:</td><td><input type="text" name="date" id="dateInput" readonly="readonly" />
                                             <script language="JavaScript">
                                             // whole calendar template can be redefined per individual calendar
                                             var A_CALTPL = {
                                                    'months' : ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
                                                    'weekdays' : ['do', 'lu', 'ma', 'mi', 'ju', 'vi', 'sa'],
                                                    'yearscroll': true,
                                                    'weekstart': 0,
                                                    'centyear'  : 70,
                                                    'imgpath' : 'js/img/'
                                                }
                                                new tcal ({
                                                    // if referenced by ID then form name is not required
                                                    'controlname': 'dateInput'
                                                }, A_CALTPL);
                                             </script>
                        </td></tr>
                        <tr><td colspan="2" align="center"><input type="submit" name="submitForm" value="Buscar"/>
                        </table>
                        </form>
                        <hr>
                        <%if(theaters != null){%>
                        <p align="center">A continuaci&oacute;n se muestran las obras de teatro disponibles: </p>
                            <table>
                                <tr>
                                    <td><b>Nombre</b></td>
                                    <td><b>Hora</b></td>
                                    <td><b>Duracion</b></td>
                                    <td><b>Cupos Disponibles</b></td>
                                    <td><b>Costo</b></td>
                                </tr>
                                <%for(int i = 0; i<theaters.size(); i++){%>
                                    <tr>
                                        <td><%=theaters.get(i).getNombre() %></td>
                                        <td><%=theaters.get(i).getHora() %></td>
                                        <td><%=theaters.get(i).getDuracion() %></td>
                                        <td>Centro: <%=theaters.get(i).getCuposdisponibles1() %> Cupos</td>
                                        <td><%=theaters.get(i).getCosto1() %> USD</td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td>Lateral Izquierdo: <%=theaters.get(i).getCuposdisponibles2() %> Cupos</td>
                                        <td><%=theaters.get(i).getCosto2() %> USD</td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td>Lateral Derecho: <%=theaters.get(i).getCuposdisponibles3() %> Cupos</td>
                                        <td><%=theaters.get(i).getCosto3() %> USD</td>
                                    </tr>
                                <%}%>
                            </table>
                        <%}else{%>
                            No Hay Resultados disponibles.
                        <%}%>
                    </div>
        </td> </tr> </tbody> </table>
                </div>
        <jsp:include page="fragment/down.jsp"/>

    </center>
</html>
